<template>
  <div class="rank">
    <a-table :dataSource="data" :columns="columns" :pagination="pagination" size="small" >
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'rankname'">
          <div :class="rankBg.includes(Number(record.rankname)) ? 'rank-first' : 'rank-name'">
            {{ record.rankname }}
          </div>
        </template>
        <template v-if="column.key === 'action'">
          <a @click="handleInfo(record)">查看详情</a>
        </template>
      </template>
    </a-table>
  </div>
</template>

<script lang="ts" setup>
import {defineExpose, ref} from 'vue';
import {router} from "/@/router";
import {dateFormat} from "/@/utils/common/compUtils";
import {queryParam} from "/@/views/xindian/reconciliation/statistics/area/areaSta.data";

const props = defineProps({
    columns: {
      type: Array,
      default: () => [],
    },
    query:{
      type: Object,
      default: () => {},
    },
    data: {
      type: Array,
      default: () => [],
    },
  });
  const rankBg = [1, 2, 3];

  const pagination = ref({
    pageSize: 7,
  });

  function handleInfo(record){
    console.info("cccccc");
    console.info(record);
    let data = props.query
    const format = 'yyyy-MM-dd';
    const begin = dateFormat(data.timeRange[0], format);
    const end = dateFormat(data.timeRange[1], format);
    router.push({name:'statisticsAreaStaList', query: {
        areaId: record.areaId,
        payBegin: begin,
        company: data.company,
        platform: data.platform,
        payEnd: end,
        salesmanId: record.id
      }})
  }

</script>

<style lang="less" scoped>
  .rank {
    width: 50%;
  }
  .rank-first {
    color: #fff;
    background-color: #1677ff;
    width: 30px;
    height: 30px;
    border-radius: 15px;
    text-align: center;
    line-height: 30px;
  }
  .rank-name {
    text-align: center;
    line-height: 30px;
    width: 30px;
    height: 30px;
  }
</style>
